/* 
    对数器
*/
let check = function (testTimes, methodA, methodB) {
    for (let times = 0; times < testTimes; times++) {
        let { arr, search } = generateArr(500, 1200);
        let resA = methodA(arr, search);
        let resB = methodB(arr, search);
        if (JSON.stringify(resA) !== JSON.stringify(resB)) {
            console.log(search, JSON.stringify(resA), JSON.stringify(resB));
            return false;
        }
    }
    return true;
};

function generateArr(maxSize, maxValue) {
    let size = Math.floor((maxSize + 1) * Math.random());
    let arr = new Array(size);
    for (let index = 0; index < arr.length; index++) {
        arr[index] = Math.floor((maxValue + 1) * Math.random()) - Math.floor((maxValue + 1) * Math.random());
    }
    let search = Math.floor((maxValue + 1) * Math.random());
    // console.log(arr);
    arr = insertSort(arr);
    return {
        arr,
        search
    };
}
let { origin } = require('./最左侧数字原始');
let { leftestNum } = require('./最左侧数字');
let { insertSort } = require('./插入排序');

let res = check(1000, origin, leftestNum);
console.log(res);
